import os, pygame

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600

def loadImage( name ):
    fullname = os.path.join( "data", name )

    try:
        image = pygame.image.load( fullname )
    except pygame.error, message:
        print "Cannot load image:", fullname
        raise SystemExit, message
    return image.convert_alpha()

class Player(pygame.sprite.Sprite):
    def __init__(self, top, left):
        pygame.sprite.Sprite.__init__(self)
        self.images     = [loadImage("bird%d.png" % i) for i in range(1,8)]
        self.image      = self.images[0]
        self.rect       = self.image.get_rect()
        self.rect.top   = top
        self.rect.left  = left
        self.frame      = 0
        self.x_velocity = 0
        self.y_velocity = 0
        
    def update(self):
        self.rect.move_ip( (self.x_velocity, self.y_velocity) )
            
        self.frame += 1
        
        speed       = 10 - self.x_velocity
        self.image  = self.images[self.frame/speed%7]
        
